import QtQuick 1.1
//import ShellInvoker 1.0
import "../../../common/lib/kdeadmouseutils-build-desktop"



Flipable {
     id: flipable
     width: 800; height: 600 
     anchors.centerIn: parent
     property bool flipped: false
     focus: true
     onFocusChanged : console.log('flipable getFocus:' + focus);
    
     transform: Rotation {
         id: rotation
         origin.x: flipable.width/2
         origin.y: flipable.height/2
         axis.x: 0; axis.y: 1; axis.z: 0     // set axis.y to 1 to rotate around y-axis
         angle: 0    // the default angle
     }

     states: [State {
         name: "back"
         PropertyChanges { target: rotation; angle: 180 }
         PropertyChanges { target: gridV;focus: false }
	  PropertyChanges { target: diapo;focus: true }
         when: flipable.flipped
      }
      ,State {
	  name: "front"
	  PropertyChanges { target: rotation; angle: 0 }
	  //PropertyChanges { target: listLoader.item;focus: true }
	  PropertyChanges { target: diapo;focus: false }
	  PropertyChanges { target: gridV;focus: true }
	  //PropertyChanges { target: detLoader;focus: false }
	   //when: listVisible
	}]

     transitions: Transition {
         NumberAnimation { target: rotation; property: "angle"; duration: 500 }
     }
     Component.onCompleted: {
	state='front';
     }
    
     
     ListModel {
         id: appModel
         ListElement { name: "Ileana"; url: "https://picasaweb.google.com/data/feed/base/user/112103620701242175348?alt=atom&kind=photo&hl=fr&access=public" }
         ListElement { name: "LocalDisk"; path: "/home/manu/Images" }
         ListElement { name: "Photos Cassie"; url: "https://picasaweb.google.com/data/feed/base/user/104816649679110227497?alt=atom&kind=photo&hl=fr&access=public" }
         ListElement { name: "lindo Planeta terra"; url: "https://picasaweb.google.com/data/feed/base/user/105325803022638572641?alt=atom&kind=photo&hl=fr&access=public" }
         ListElement { name: "Ileana3"; url: "https://picasaweb.google.com/data/feed/base/user/112103620701242175348?alt=atom&kind=photo&hl=fr&access=public" }
         
     }
      
     MouseArea {
         anchors.fill: parent
         onClicked: {
	   if(flipable.state=='back')
	     flipable.state='front'
	   else
	     flipable.state='back';
	}
     }
     
    back : Diapo {
      id:diapo
      anchors.fill: parent
      focus: true
      onFocusChanged : console.log('diapo getFocus:' + focus);
      Keys.onPressed: {
          if(event.key == Qt.Key_Backspace) {
	    console.log('go front');
	    flipable.state='front';
	  }
      }
    }  
      
    front : Rectangle {
      anchors.fill: parent
      color: "Black" 
      focus: false
      onFocusChanged : console.log('front getFocus:' + focus);
      GridView {
	  id:gridV
	  anchors.fill: parent
	  cellWidth: 440; cellHeight: 300
	  flow : GridView.TopToBottom
	  focus: true
	  onFocusChanged : console.log('grid getFocus:' + focus);
	  model: appModel
	  delegate : 
	  Apercu{
	    id:apercu
	    picasaUrl:url
	    sPath:path
	    Keys.onReturnPressed: {
	      console.log('selected:' + picasaUrl);
	      console.log('photoModelManager:' + photoModelManager);
	      diapo.modelManager = photoModelManager;
	      flipable.state='back'
	    }
	  }
      }
 }
 
}
